import 'package:flutter/material.dart';

class TabButton extends StatefulWidget {
  const TabButton(
      {Key? key,
      this.icon,
      this.onTap,
      this.tooltip = '',
      this.selected = false})
      : super(key: key);
  final IconData? icon;
  final Function? onTap;
  final String tooltip;
  final bool selected;
  @override
  _TabButtonState createState() => _TabButtonState();
}

class _TabButtonState extends State<TabButton> {
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 2),
      child: Tooltip(
        message: widget.tooltip,
        child: Container(
          alignment: Alignment.center,
          width: 30,
          decoration: BoxDecoration(
            color: widget.selected == false ? Colors.transparent : Colors.blue,
            borderRadius: const BorderRadius.all(
              Radius.circular(5.0),
            ),
          ),
          child: Material(
            type: MaterialType.transparency,
            child: InkWell(
              borderRadius: const BorderRadius.all(Radius.circular(5.0)),
              onTap: () => widget.onTap!(),
              child: Center(
                child: Icon(
                  widget.icon,
                  color: widget.selected == false ? Colors.black : Colors.white,
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
